import { Nodes } from '@knno/dom';
import { Radio as UIRadio } from '../components/radio/radio';
import { JSXProps } from '@knno/dom/jsx';
import { AttrCheck, isBool, isObject, isStr, jsxBuild } from './utils';
import { FacadeIcons } from '../components/checkbox/checkable';

export { UIRadio };

interface RadioProps extends JSXProps<UIRadio> {
	checked?: boolean;
	text?: string;
	value?: unknown;
	group?: string;
	disabled?: boolean;
	uncheckable?: boolean;
	facadeIcons?: FacadeIcons;
}

const ATTRS: AttrCheck = {
	checked: isBool,
	group: isStr,
	text: isStr,
	disabled: isBool,
	facadeIcons: isObject,
	uncheckable: isBool,
};

export function Radio(props: RadioProps, children: Nodes[]): UIRadio {
	return jsxBuild(new UIRadio(), props, children, ATTRS);
}
